﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ass1_from
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string input1 = textBox1.Text;
            string input2 = textBox2.Text;
            if (input1 == "" | input2 == "")
            {
                label2.Text = "运算数不可为空！";
            }
            else
            {
                double acc1 = double.Parse(input1);
                double acc2 = double.Parse(input2);
                //没有选
                if (checkBox1.Checked == false && checkBox2.Checked == false && checkBox3.Checked == false && checkBox4.Checked == false)
                {
                    label2.Text = "请选择运算类型！";
                }
                //选了一个 
                else if ((checkBox1.Checked == true && checkBox2.Checked == false && checkBox3.Checked == false && checkBox4.Checked == false) | (checkBox1.Checked == false && checkBox2.Checked == true && checkBox3.Checked == false && checkBox4.Checked == false) | (checkBox1.Checked == false && checkBox2.Checked == false && checkBox3.Checked == true && checkBox4.Checked == false) | (checkBox1.Checked == false && checkBox2.Checked == false && checkBox3.Checked == false && checkBox4.Checked == true))
                {
                    if (checkBox1.Checked)
                    {
                        double result = acc1 + acc2;
                        label2.Text = "运算结果是：";
                        string m = result.ToString();
                        textBox3.Text = m;

                    }
                    if (checkBox2.Checked)
                    {
                        double result = acc1 - acc2;
                        label2.Text = "运算结果是：";
                        string m = result.ToString();
                        textBox3.Text = m;
                    }
                    if (checkBox3.Checked)
                    {
                        double result = acc1 * acc2;
                        label2.Text = "运算结果是：";
                        string m = result.ToString();
                        textBox3.Text = m;
                    }
                    if (checkBox4.Checked)
                    {
                        double result1 = acc1 / acc2;
                        label2.Text = "运算结果是：";
                        string n = result1.ToString();
                        textBox3.Text = n;
                    }

                }
                //选多个
                else
                {
                    label2.Text = "只能选择一种运算类型！";
                }
            }
        }
    }
}
